﻿#include<stdio.h>
#include<stdlib.h>

typedef struct BinaryNode {
	struct BinaryNode* left;
	struct BinaryNode* right;
	char ch;
}BTNode;

BTNode* BTBuyNode(char ch) {
	BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
	if (newnode == NULL) {
		perror("malloc fail");
		return NULL;
	}
	newnode->ch = ch;
	newnode->left = newnode->right;
}
void inOrder(BTNode* root) {
	if (root == NULL) {
		return;
	}
	printf("%c ", root->ch);
	inOrder(root->left);
	inOrder(root->right);
}
BTNode* TreeCreate(char* arr, int* pi) {
	if (arr[*pi] == '#') {
		(*pi)++;
		return NULL;
	}
	BTNode* root = BTBuyNode(arr[(*pi)++]);
	root->left = TreeCreate(arr, pi);
	root->right = TreeCreate(arr, pi);
	return root;
}

int main() {
	char arr[100];
	scanf("%s");
	int i = 0;
	BTNode* root=TreeCreate(arr, &i);
	inOrder(root);
	return 0;
}